# 合并后的test_all.py
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def generate_test_cases():
    case1 = TreeNode(1)
    case1.left = TreeNode(2)
    case1.right = TreeNode(3)
    case1.left.right = TreeNode(5)
    
    case2 = TreeNode(1)
    
    case3 = TreeNode(1)
    case3.left = TreeNode(2)
    case3.right = TreeNode(3)
    case3.left.left = TreeNode(4)
    case3.left.right = TreeNode(5)
    case3.right.left = TreeNode(6)
    case3.right.right = TreeNode(7)
    
    return [case1, case2, case3]

class Solution:
    def binaryTreePaths(self, root):
        def backtrack(node, path, res):
            if not node: return
            path.append(str(node.val))
            if not node.left and not node.right:
                res.append("->".join(path))
            backtrack(node.left, path, res)
            backtrack(node.right, path, res)
            path.pop()
        res = []
        backtrack(root, [], res)
        return res

if __name__ == "__main__":
    cases = generate_test_cases()
    sol = Solution()
    for i, case in enumerate(cases, 1):
        print(f"测试用例 {i}:")
        print("结果:", sol.binaryTreePaths(case))